package com.hongyu.smart.village.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.hongyu.smart.village.R;
import com.hongyu.smart.village.model.HomeMenu;
import com.hongyu.smart.village.ui.base.BaseAdapter;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class HomeMenuAdapter extends BaseAdapter<HomeMenu,HomeMenuAdapter.ViewHolder> {
    public HomeMenuAdapter(Context mContext, List<HomeMenu> mList) {
        super(mContext, mList);
    }

    @Override
    protected ViewHolder getViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    public int getItemView() {
        return R.layout.itme_home_menu;
    }


    @Override
    public void onBindHolder(ViewHolder holder, int position) {
        HomeMenu bean = mList.get(position);
            holder.tvName.setText(bean.getName());
            holder.ivPic.setImageResource(bean.getImageres());
    }


    static class ViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.iv_pic)
        ImageView ivPic;


        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}